<html>
<head><meta charset="utf-8"><title>Next steps for the group · project-inline-asm · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/index.html">project-inline-asm</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Next.20steps.20for.20the.20group.html">Next steps for the group</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="197562092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Next%20steps%20for%20the%20group/near/197562092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Next.20steps.20for.20the.20group.html#197562092">(May 14 2020 at 14:20)</a>:</h4>
<p>The inline assembly RFC has a <a href="https://github.com/Amanieu/rfcs/blob/inline-asm/text/0000-inline-asm.md#future-possibilities">list</a> of future possibilities for features to add to inline assembly.</p>



<a name="197562137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Next%20steps%20for%20the%20group/near/197562137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Next.20steps.20for.20the.20group.html#197562137">(May 14 2020 at 14:20)</a>:</h4>
<p>I personally feel that these two are the most promising:</p>
<ul>
<li>const and sym for global_asm!</li>
<li>Clobbers for function calls</li>
</ul>



<a name="197562883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Next%20steps%20for%20the%20group/near/197562883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Next.20steps.20for.20the.20group.html#197562883">(May 14 2020 at 14:27)</a>:</h4>
<p>I'm particularly interested in bringing <code>global_asm!</code> up to speed with the new features of <code>asm!</code>. As a bonus, this would allow us to deprecate the existing naked function support and replace it with a proc macro.</p>



<a name="197563027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Next%20steps%20for%20the%20group/near/197563027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Next.20steps.20for.20the.20group.html#197563027">(May 14 2020 at 14:28)</a>:</h4>
<p>The clobber support feels important since it fills in a usability hole with <code>asm!</code>: you can't reliably mark all registers as clobbered if the ISA can add new registers in the future.</p>



<a name="197592007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Next%20steps%20for%20the%20group/near/197592007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Next.20steps.20for.20the.20group.html#197592007">(May 14 2020 at 17:46)</a>:</h4>
<p>So, a "clobber all registers that a function call is considered to clobber on the native ABI" clobber?</p>



<a name="197592031"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Next%20steps%20for%20the%20group/near/197592031" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Next.20steps.20for.20the.20group.html#197592031">(May 14 2020 at 17:46)</a>:</h4>
<p>That seems like a great idea to me.</p>



<a name="197592139"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Next%20steps%20for%20the%20group/near/197592139" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Next.20steps.20for.20the.20group.html#197592139">(May 14 2020 at 17:47)</a>:</h4>
<p>I personally am excited about having a structured, <code>if</code>-like or <code>match</code>-like construct that can effectively replace <code>asm goto</code>.</p>



<a name="197592640"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Next%20steps%20for%20the%20group/near/197592640" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Next.20steps.20for.20the.20group.html#197592640">(May 14 2020 at 17:51)</a>:</h4>
<p>I'm less excited about asm goto since it is likely to be very difficult to implement and it doesn't really enable any new use cases like the two features I mentioned above: you can always emulate asm goto by returning an int and matching on that.</p>



<a name="197594090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Next%20steps%20for%20the%20group/near/197594090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Next.20steps.20for.20the.20group.html#197594090">(May 14 2020 at 18:00)</a>:</h4>
<p>It does enable a specific new use case: static branches that use unconditional jumps and are binary-patchable.</p>



<a name="197594130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Next%20steps%20for%20the%20group/near/197594130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Next.20steps.20for.20the.20group.html#197594130">(May 14 2020 at 18:01)</a>:</h4>
<p>The Linux kernel uses many of those, for performance-sensitive code.</p>



<a name="197594216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Next%20steps%20for%20the%20group/near/197594216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Next.20steps.20for.20the.20group.html#197594216">(May 14 2020 at 18:01)</a>:</h4>
<p>The goal is to completely eliminate the conditional.</p>



<a name="197620030"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Next%20steps%20for%20the%20group/near/197620030" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Next.20steps.20for.20the.20group.html#197620030">(May 14 2020 at 21:23)</a>:</h4>
<p>When global_asm gets worked on, I hope that we can give it the <code>link_section</code> attribute (I don't know if that's already possible). This would allow me to pull my project's equivalent for the "crt0.s" entirely inside of rust and then I'd only need to do a little linker script magic, wouldn't need to directly call the assembler (from <code>build.rs</code>) at all.</p>



<a name="197624671"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Next%20steps%20for%20the%20group/near/197624671" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Next.20steps.20for.20the.20group.html#197624671">(May 14 2020 at 22:09)</a>:</h4>
<p>There won't be any attributes on <code>global_asm!</code> itself but you can use assembler directives inside it.</p>



<a name="197624732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Next%20steps%20for%20the%20group/near/197624732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Next.20steps.20for.20the.20group.html#197624732">(May 14 2020 at 22:10)</a>:</h4>
<p>Essentially you would do <code>global_asm!(include_str!("crt0.s"))</code></p>



<a name="197624777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Next%20steps%20for%20the%20group/near/197624777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Next.20steps.20for.20the.20group.html#197624777">(May 14 2020 at 22:10)</a>:</h4>
<p>In fact, you can already do that today.</p>



<a name="197624915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Next%20steps%20for%20the%20group/near/197624915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Next.20steps.20for.20the.20group.html#197624915">(May 14 2020 at 22:12)</a>:</h4>
<p>The only changes I want to make to <code>global_asm</code> are:</p>
<ul>
<li>Using intel syntax by default to match <code>asm!</code>.</li>
<li>Allowing <code>const</code> and <code>sym</code> operands like <code>asm!</code>.</li>
</ul>



<a name="197626620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Next%20steps%20for%20the%20group/near/197626620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Next.20steps.20for.20the.20group.html#197626620">(May 14 2020 at 22:31)</a>:</h4>
<p>I'm assuming it'll support the <code>att_syntax</code> option?</p>



<a name="197626849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Next%20steps%20for%20the%20group/near/197626849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Next.20steps.20for.20the.20group.html#197626849">(May 14 2020 at 22:33)</a>:</h4>
<p>Looking over the entire <code>asm!</code> RFC again, I don't see anything else that would need changing in <code>global_asm!</code>, yeah.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>